package com.zjw.concurrency.juc.threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ThreadlocalExample_01 {

    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                String date = date(20);
                System.out.println(Thread.currentThread().getName() + ":" + date);
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                String date = date(16);
                System.out.println(Thread.currentThread().getName() + ":" + date);
            }
        }).start();

        //lambda表达式启动线程
        new Thread(()->{
            String date = date(67);
            System.out.println(Thread.currentThread().getName() + ":" + date);
        }).start();
    }

    public static String date(int second){

        Date date = new Date(second * 1000);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String dateString = simpleDateFormat.format(date);
        return dateString;
    }
}
